<%@ page import="pizza.admin.entity.User"%>

<%
	User adminUser = null;
	
	if (session.getAttribute("user") != null) {
		adminUser = (User) session.getAttribute("user");
	}

	if (adminUser == null) {
		response.sendRedirect("/");
	}
	
	User user = new User();

	if(request.getAttribute("user")!=null) {
		user = (User) request.getAttribute("user");
	}
%>
<jsp:include page="../../layout/header.jsp" flush="true" />
<div class="container">

	<h3>Users</h3>
	<div class="main row-fluid">
		
		<%if(request.getMethod()=="POST"&&!user.validateForDB()){ %>
        	<div class="alert alert-error">All fields with * are required and username must be unique!</div>
        <% }%>
		<span class="span12 ">
			<form name='' method='post' action=''>
				<label class="control-label" for="inputName">Name</label>
				<div class="controls">
					<input name="name" type="text" id="inputName"
						value='<%=user.getName()%>'>
				</div>
				<label class="control-label" for="inputSurname">Surname</label>
				<div class="controls">
					<input name="surname" type="text" id="inputSurname"
						value='<%=user.getSurname()%>'>
				</div>
				<label class="control-label" for="inputUsername">Username (5 symbols min) *</label>
				<div class="controls">
					<input name="username" type="text" id="inputUsername"
						value='<%=user.getUsername()%>'>
				</div>
				<label class="control-label" for="inputPassword">Password (5 symbols min)*</label>
				<div class="controls">
					<input name="password" type="password" id="inputPassword"
						value='<%=user.getPassword()%>'>
				</div>
				<label class="control-label" for="inputPasswordRepeat">Password
					repeat (5 symbols min)*</label>
				<div class="controls">
					<input name="passwordRepeat" type="password"
						id="inputPasswordRepeat" value='<%=user.getPasswordRepeat()%>'>
				</div>
				
				<div class="controls">
					<br>
					<input type="submit" name="submit" id="submit" value='Save'
						class='btn btn-primary'>
				</div>
			</form>
		</span>
	</div>
</div>
<!-- /container -->

<jsp:include page="../../layout/footer.jsp" flush="true" />